package com.wjd.store;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

/**
 * 页面存储器
 *
 * @author weijiaduo
 * @since 2024/3/18
 */
public class PageStore extends RecordTree<PageRecord> {

    public PageStore(String baseDir) throws IOException {
        super(baseDir);
    }

    public PageStore(String baseDir, String ext) throws IOException {
        super(baseDir, ext);
    }

    @Override
    protected PageRecord readRecord(DataInputStream in) throws IOException {
        String url = in.readUTF();
        int pv = in.readInt();
        String title = in.readUTF();
        String content = in.readUTF();
        return new PageRecord(url, pv, title, content);
    }

    @Override
    protected void writeRecord(DataOutputStream out, PageRecord record) throws IOException {
        out.writeUTF(record.getUrl());
        out.writeInt(record.getPageValue());
        out.writeUTF(record.getTitle());
        out.writeUTF(record.getContent());
    }

}
